/*
 * Copyright (c) Jiandong.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import { YogaNative } from './YogaNative';
import { YogaConfig } from './YogaConfig';
import { YogaNodeNAPIBase } from './YogaNodeNAPIBase';
/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */


export class YogaNodeJNIFinalizer extends YogaNodeNAPIBase {
//  public constructor() {
//    super();
//  }

  public constructor(config?: YogaConfig) {
    super(config);
  }

//  @Override
  protected finalize(): void | never {
    try {
      this.freeNatives();
    } finally {
      // super.finalize();
    }
   }

  public freeNatives(): void {
    if (this.mNativePointer != 0) {
      let nativePointer: number = this.mNativePointer; // long
      this.mNativePointer = 0;
      YogaNative.napi_YGNodeFreeNAPI(nativePointer);
    }
  }
}
